import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN'
import App from './App'
import router from './router'
import store from './store'
import '@/icons' // icon
import '@/permission' // 权限
import VueAMap from 'vue-amap'
import './styles/wwCss.css'
import { getLoginUser } from './utils/auth'
import echarts from 'echarts'

Vue.prototype.$echarts = echarts
Vue.use(VueAMap)
VueAMap.initAMapApiLoader({
  key: '0f44ca15f471da87fede8221b1ee1587',
  plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'MarkerClusterer']
})

Vue.directive('role', (el, binding, vnode) => {
  const val = binding.value
  if (val) { // 不为空
    const authorities = getLoginUser().authorities
    let isHide = true
    for (let i = 0; i < val.length; i++) {
      if (authorities.indexOf(val[i]) >= 0) {
        isHide = false
        break
      }
    }
    if (isHide) {
      el.style.display = 'none'
    }
  }
})

Vue.use(ElementUI, { locale })
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
